#define _CRT_SECURE_NO_WARNINGS

class Solution {
public:
    string modifyString(string s) {
        for (int i = 1; i < s.size() - 1; i++)
        {
            if (s[i] == '?')
            {
                for (char j = 'a'; j <= 'z'; j++)
                {
                    if (s[i - 1] != j && s[i + 1] != j)
                    {
                        s[i] = j;
                        break;
                    }
                }
            }
        }

        if (s.size() == 1 && s[0] == '?')
            s[0] = 'a';

        if (s[0] == '?')
        {
            if (s[1] == 'a' || s[1] == 'z')
                s[0] = 'b';
            else
                s[0] = 'a';
        }
        if (s[s.size() - 1] == '?')
        {
            if (s[s.size() - 2] == 'a' || s[s.size() - 2] == 'z')
                s[s.size() - 1] = 'b';
            else
                s[s.size() - 1] = 'a';
        }

        return s;
    }
};